<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>模拟器配置列表</title>
<@fm.header />
<script type="text/javascript" src="/resources/js/easyui/jquery.edatagrid.js"></script>
<style type="text/css">
body {
	font: 12px/20px "微软雅黑", "宋体", Arial, sans-serif, Verdana, Tahoma;
	padding: 0;
	margin: 0;
}
.layout-split-proxy-h{
	position:absolute;
	width:2px;
	background:#888;
	font-size:1px;
	cursor:e-resize;
	display:none;
	z-index:5;
}
.layout-split-north{
	border-bottom:5px solid #efefef;
}
.layout-split-south{
	border-top:5px solid #efefef;
}
.layout-split-east{
	border-left:0px solid #efefef;
}
.layout-split-west{
	border-right:0px solid #efefef;
}
a:link {
 text-decoration: none;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: underline;
}
a:active {
 text-decoration: none;
}
.cs-north {
	height:40px;
	overflow:hidden;
}
.cs-north-bg {
	width: 100%;
	height: 100%;
	background: url(/resources/js/easyui/themes/bootstrap/images/header_bg.png) repeat-x;
}
.cs-north-logo {
	height: 30px;
	margin: 10px 0px 20px 5px;
	display: inline-block;
	color:#0E2D5F;
	font-size:20px;
	font-weight:bold;
	text-decoration:none;
}
.cs-north-info {
	position: absolute;
	color: #777;
	top: 10px;
	right: 30px;
	display: inline-block;
}
</style>
</head>
<body class="cmp-list-body">
	<input type="hidden" name="repoId" id="repoId" value="${csi.repoId!}">
	<div id="mainPanle" region="center" border="false">
		<table id="tt" class="easyui-datagrid" title="脚本列表" iconCls="icon-save" toolbar="#tb" rownumbers="true" idField="id"
			url="/script/configScriptNumListjson?repoId=${csi.repoId!}" singleSelect="true"
			pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
		    <thead>		    
		    	<tr>
		        	<th align="center" width="20%" field="name">名称</th>
		            <th align="center" width="20%" field="filePath">路径</th>
		            <th align="center" width="10%" field="type" formatter="formatType">类型</th>
		            <th align="center" width="5%" field="num" editor="{type:'validatebox'}">执行量</th>
		        </tr>
		    </thead>   
		</table>
	</div>
	
<script>
function formatType(value, row, index){
	if (value == 1) {
		return "新增";
	} else {
		return "留存";
	}
}

$(function() {
	$('#tt').edatagrid({
		onClickRow : function(index, row) {
			 if(checkEnding()){
				 editIndex = index;
	         }
			if (row.loginType != 1 && row.loginType != 13) {
				$('#tt').datagrid('selectRow',index).datagrid('beginEdit',index)
				endEditing(index, 'payRate');
				endEditing(index, 'payMin');
				endEditing(index, 'payMax');
			}
		},
		onAfterEdit : function(rowIndex, rowData, changes) {
			$.ajax({
				url : '/script/saveConfigScriptNum',
				data : {
					name: rowData.name,
			        repoId: rowData.repoId,
			        filePath: rowData.filePath,
			        num: rowData.num
				},
				type : 'POST'
			});
		},
		onCancelEdit:function(index,row){
			row.editing = false;
			$('#tt').datagrid('updateRow',{
				index: index,
				row:{}
			});
		}
	})
	
	 var editIndex = undefined;
	 function checkEnding(){
         if(editIndex == undefined) {
        	 return true;
         }
         if($('#tt').datagrid('validateRow',editIndex)) {
             $('#tt').datagrid('endEdit',editIndex);
             editIndex = undefined; 
             return true;
          }else{
        	  return false;
          }
      }

	
	function endEditing(index, field){
		var cellEdit = $('#tt').datagrid('getEditor', {
			index : index,
			field : field
		});
		var $input = cellEdit.target; 
		$input.attr("disabled", true);
	}
});
</script>
</body>
</html>